﻿using System;
using T4UtilityBelt.Templates;

namespace T4UtilityBelt.DataDesigns.Renderers
{
    public abstract class Renderer<T> : IRenderer
        where T : Property
    {
        public Type EntityType
        {
            get { return typeof(T); }
        }

        public Template Template { get; set; }

        public void Write(string text)
        {
            Template.Write(text);
        }


        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Property")]
        public abstract void Render(T property);

        public void RenderProperty(object property)
        {
            T p = property as T;
            if (p != null)
            {
                Render(p);
            }
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Property")]
        public virtual void Render2(T property)
        {
            Render(property);
        }

        public void Render2Property(object property)
        {
            T p = property as T;
            if (p != null)
            {
                Render2(p);
            }
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Property")]
        public virtual void Render3(T property)
        {
            
        }

        public void Render3Property(object property)
        {
            T p = property as T;
            if (p != null)
            {
                Render3(p);
            }
        }

    }
}